{template '_header'}
<div class='page-heading'>
    <span class='pull-right'>
            {ifp 'sale.coupon.add'}
					 <a class='btn btn-primary btn-sm' href="{php echo merchUrl('sale/coupon/add')}"><i class='fa fa-plus'></i> 添加购物优惠券</a>
				       {/if}
    </span>
    <h2>优惠券管理 <small>总数: <span class='text-danger'>{$total}</span> 排序数字越大越靠前显示</small></h2></div>


   <form action="./merchant.php" method="get" class="form-horizontal table-search" role="form" id="form1">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="ewei_shopv2" />
            <input type="hidden" name="do" value="web" />
            <input type="hidden" name="r" value="sale.coupon" />
<div class="page-toolbar row m-b-sm m-t-sm">
                            <div class="col-sm-1">
				 
			  <div class="input-group-btn">
			        <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
				 
				{ifp 'sale.coupon.delete'}	
			        <button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo merchUrl('sale/coupon/delete')}"><i class='fa fa-trash'></i> 删除</button>
					{/if}
		
				
			   </div>  
			
                               </div>	
	  
				 
                            <div class="col-sm-11 pull-right">
			 <div class='input-group input-group-sm' style='float:left;'   >
				   {php echo tpl_daterange('time', array('placeholder'=>'创建时间'),true);}
			</div>  
                                
                                 <select name='gettype'  class='form-control  input-sm select-md'   style="width:100px;padding:0 5px;"  >
                        <option value=''>领券中心</option>
                        <option value='0' {if $_GPC['gettype']=='0'}selected{/if}>不显示</option>
                        <option value='1' {if $_GPC['gettype']=='1'}selected{/if}>显示</option>
                    </select>
                                
	  <select name='type' class='form-control  input-sm select-md'   style="width:100px;"  >
                        <option value=''>类型</option>
                        <option value='0' {if $_GPC['type']=='0'}selected{/if}>购物</option>
                        <option value='1' {if $_GPC['type']=='1'}selected{/if}>充值</option>
                    </select>
                                
                                <select name='catid' class='form-control  input-sm select-md'   style="width:100px;"  >
				<option value=''>分类</option>
				{loop $category $k $c}
					<option value='{$k}' {if $_GPC['catid']==$k}selected{/if}>{$c['name']}</option>
			          {/loop}
			</select>
                                
				<div class="input-group">				 
                                        <input type="text" class="input-sm form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="优惠券名称"> <span class="input-group-btn">
						
                                     <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
                                </div>
								
                            </div>
</div>
  </form>
    
{if count($list)>0}
        <table class="table table-hover table-responsive">
            <thead class="navbar-inner" >
                <tr>
                    <th style="width:25px;"><input type='checkbox' /></th>
                     <th style="width:50px;">排序</th>
                     <th style="width:180px;">优惠券名称</th>
                     <th style="width:120px;" >使用条件<br/>优惠<br/>剩余数量</th>
	    <th style="width:80px;">领取中心</th>
                    <th style="width:100px;">创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                      	<td>
									<input type='checkbox'   value="{$row['id']}"/>
							</td>
					  <td>
			  {ifp 'sale.coupon.edit'}
				<a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo merchUrl('sale/coupon/displayorder',array('id'=>$row['id']))}" >{$row['displayorder']}</a>
				{else}
				{$row['displayorder']} 
				{/if}
						</td>
                
		    <td>{if $row['coupontype']==0}
				  <label class='label label-success'>购物</label>
						  {else}
						  <label class='label label-warning'>充值</label>
					 {/if}
					 {if !empty($row['catid'])}
					 <label class='label label-primary'>{$category[$row['catid']]['name']}</label>
					 {/if}
					 <br/>{$row['couponname']}
					  </td>
					  <td>{if $row['enough']>0}
						  <label class="label label-danger">满{$row['enough']}可用</label>
						  {else}
						    <label class="label label-warning">不限</label>
						  {/if}
					 
						  {if $row['backtype']==0}
						  <br/>立减 {$row['deduct']} 元
						  {else if $row['backtype']==1}
						  <br/>打 {$row['discount']} 折
						  {else if $row['backtype']==2}
                                                                                                                       {if $row['backmoney']>0}<br/>返 {$row['backmoney']} 余额;{/if}
						  {if $row['backcredit']>0}<br/>返 {$row['backcredit']} 积分;{/if}
						  {if $row['backredpack']>0}<br/>返 {$row['backredpack']} 红包;{/if}
						  {/if}
                                                  <br/>
                                                    {ifp 'coupon.log.view'}
                                            <a href="{php echo merchUrl('sale/coupon/log',array('couponid'=>$row['id']))}"
                                               data-toggle='popover'
                                               data-html='true'
                                               data-trigger='hover'
                                               data-content="已使用: {$row['usetotal']} <br/> 已发出: {$row['gettotal']}">
                                                {if $row['total']==-1}无限{else}{php echo $row['total'] -  $row['gettotal']}{/if} <i class='fa fa-question-circle'></i>
                                            </a>
                                            {else}
                                            <span>{if $row['total']==-1}无限{else}{php echo $row['total'] -  $row['gettotal']}{/if}</span>
                                            {/if}
					 </td>
					 
                 
                                          
                                      
                     <td>{if $row['gettype']==0}
						 <label class="label label-default">不显示</label>
						 {else}
						 
						 {if $row['credit']>0 || $row['money']>0}
						 {if $row['credit']>0}<label class='label label-primary'>{$row['credit']} 积分</label><br/>{/if}
						 {if $row['money']>0}<label class='label label-danger'>{$row['money']} 现金</label><br/>{/if}
						 {else}
						 <label class='label label-warning'>免费</label>
						 {/if}
					 {/if}
					 </td>
                      <td>{php echo date('Y-m-d',$row['createtime'])}<br/>{php echo date('H:i',$row['createtime'])}</td>
					<td>
                                            
						<div class="btn-group btn-group-sm">
						<a href="javascript:;" data-url="{php echo mobileUrl('sale/coupon/detail', array('id' => $row['id']),true)}"  class="btn btn-default btn-sm js-clip">
							<i class="fa fa-link"></i> 复制链接
						</a>
						<a href="javascript:void(0);" class="btn btn-default btn-sm" data-toggle="popover" data-trigger="hover" data-html="true"
						   data-content="<img src='{$row['qrcode']}' width='130' alt='链接二维码'>" data-placement="auto right">
							<i class="glyphicon glyphicon-qrcode"></i>
						</a>
						
                         {ifp 'sale.coupon.edit'} 
                              <a class='btn btn-default btn-sm' href="{php echo merchUrl('sale/coupon/edit',array('id' => $row['id']));}"><i class='fa fa-edit'></i> {ifp 'sale.coupon.edit'}编辑{else}查看{/if}</a>
                        {/if}
                        {ifp 'sale.coupon.delete'} 
                              <a class='btn btn-default  btn-sm' data-toggle='ajaxRemove' href="{php echo merchUrl('sale/coupon/delete',array('id' => $row['id']));}" data-confirm="确定要删除该优惠券吗？"><i class='fa fa-trash'></i> 删除</a>
                        {/if}
                       </div>

                    </td>
                </tr>
                {/loop}
            </tbody>
          
        </table>
        {$pager}
    {else}
<div class='panel panel-default'>
	<div class='panel-body' style='text-align: center;padding:30px;'>
		 暂时没有任何优惠券!
	</div>
</div>
{/if}
			     </form>
{template '_footer'}